package com.e3.sysmg.config.service;

import java.util.List;

import com.e3.core.base.ServiceLocator;
import com.e3.core.cache.CacheLoader;
import com.e3.sysmg.config.model.ParameterModel;

public class ParameterCacheLoader implements CacheLoader {
	
	private ParameterQueryService parameterQueryService;
	
	private ParameterQueryService getParameterQueryService(){
		if(parameterQueryService == null){
			parameterQueryService = ServiceLocator.getQueryService(ParameterQueryService.class);
		}
		return parameterQueryService;
	}

	public void loadeData() throws Exception {
		List<ParameterModel> models = getParameterQueryService().getAllParameters();
		if(models==null||models.isEmpty()){
			return;
		}
		for (ParameterModel model : models) {
			ParameterCacheManager.INSTANCE.put(model);
		}

	}

}
